package com.joven.core.utils;

import com.joven.core.constant.Status;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author joven_wong
 * 2021/6/24 16:57
 * 自定义异常类
 */
@NoArgsConstructor
public class BizException extends RuntimeException{
    private String errorCode;
    private String errorMsg;

    public BizException(Status status){
        super(status.getCode());
        this.errorCode = status.getCode();
        this.errorMsg = status.getMessage();
    }

    public BizException(Status status, Throwable cause){
        super(status.getCode(), cause);
        this.errorCode = status.getCode();
        this.errorMsg = status.getMessage();
    }

    public BizException(String errorMsg){
        super(errorMsg);
        this.errorMsg = errorMsg;
    }

    public BizException(String errorCode, String errorMsg) {
        super(errorCode);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public BizException(String errorCode, String errorMsg, Throwable cause) {
        super(errorCode, cause);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    @Override
    public Throwable fillInStackTrace() {
        return this;
    }
}
